package com.amos.generate.service.impl;

import com.amos.generate.bean.DataBaseField;
import com.amos.generate.service.DataBaseService;
import com.amos.generate.service.GenerateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Copyright © 2018 嘉源锐信. All rights reserved.
 *
 * @Project: mu-exam
 * @ClassName: GenerateServiceImpl
 * @Package: com.amos.generate.service.impl
 * @author: zhuqb
 * @Description:
 * @date: 2020/3/11 0011 上午 11:11
 * @Version: V1.0
 */
@Service
public class GenerateServiceImpl implements GenerateService {

    @Autowired
    private DataBaseService dataBaseService;
    @Override
    public void generateCode(String path, String packageName, String tableName, boolean isPage) {
        List<DataBaseField> list = dataBaseService.getTableFields(tableName);
        // Entity生成
        EntityHandler entityHandler = new EntityHandler(path,packageName,tableName,list);
        entityHandler.handle();
        ControllerHandler controllerHandler = new ControllerHandler(path,packageName,tableName,isPage);
        controllerHandler.handle();
        DtoHandler dtoHandler = new DtoHandler(path,packageName,tableName,isPage,list);
        dtoHandler.handle();
        ServiceHandler serviceHandler = new ServiceHandler(path,packageName,tableName,isPage);
        serviceHandler.handle();
        ServiceImplHandler serviceImplHandler = new ServiceImplHandler(path,packageName,tableName,isPage);
        serviceImplHandler.handle();
        MapperJavaHandler mapperJavaHandler = new MapperJavaHandler(path,packageName,tableName);
        mapperJavaHandler.handle();
        MapperXmlHandler mapperXmlHandler = new MapperXmlHandler(path,packageName,tableName,list);
        mapperXmlHandler.handle();
    }
}
